<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  User: dw
  Date: 2019/12/16
  Time: 23:13
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>设置我的资料</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
</head>
<body>

  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-col-md12">
        <div class="layui-card">
          <div class="layui-card-header">设置我的资料</div>
          <div class="layui-card-body" pad15>
            
            <div class="layui-form" lay-filter="">
              <div class="layui-form-item">
                <label class="layui-form-label">我的角色</label>
                <div class="layui-input-inline">
                  <select name="role" lay-verify="">
                    <option value="1" selected>超级管理员</option>
                    <option value="2" disabled>普通管理员</option>
                    <option value="3" disabled>审核员</option>
                    <option value="4" disabled>编辑人员</option>
                  </select> 
                </div>
                <div class="layui-form-mid layui-word-aux">当前角色不可更改为其它角色</div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">姓名</label>
                <div class="layui-input-inline">
                  <input type="text" name="userName" value="${sessionScope.user.userName}" class="layui-input">
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">手机</label>
                <div class="layui-input-inline">
                  <input type="text" name="tel" value="${sessionScope.user.tel}" lay-verify="phone" autocomplete="off" placeholder="请输入手机号码" class="layui-input">
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">性别</label>
                <div class="layui-input-block">
                  <input type="radio" name="userGender" value="男" title="男">
                  <input type="radio" name="userGender" value="女" title="女" checked>
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">所属部门</label>
                <div class="layui-input-inline">
                  <input type="text" name="dep" value="${sessionScope.user.dep.depName}" readonly class="layui-input">
                </div>
              </div>
              <div class="layui-form-item">
                <div class="layui-input-block">
                  <button class="layui-btn" lay-submit lay-filter="setmyinfo">确认修改</button>
                  <button type="reset" class="layui-btn layui-btn-primary">重新填写</button>
                </div>
              </div>
            </div>
            
          </div>
        </div>
      </div>
    </div>
  </div>

  <script src="../../../layuiadmin/layui/layui.js"></script>  
  <script>
  layui.config({
    base: '../../../layuiadmin/' //静态资源所在路径
  }).extend({
      index: 'lib/index' //主入口模块
  }).use(['index', 'user','form','layer','laydate'], function() {
      var $ = layui.$
          , setter = layui.setter
          , admin = layui.admin
          , form = layui.form
          , router = layui.router()
          , layer = layui.layer
          , laydate = layui.laydate
          , search = router.search;
      //重置按钮
      $("button[type=reset]").on('click', function () {
          $("input[name='tel']").val("");
      });

      //更新信息
      form.on('submit(setmyinfo)', function (obj) {
          var data = obj.field;
          console.log(data);
          $.ajax({
              url: "/user/updateInfo",
              data: {'userName':data.userName,'userGender':data.userGender,'tel':data.tel},
              dataType: "json",
              type: "post",
              success: function (res) {
                  if (res.msg == "ok") {
                      layer.msg("更新成功，重新登录后生效");
                  } else {
                      layer.msg("信息完全一致不用更新！！");
                  }
              },
              error: function (e) {
                  console.log(e.responseText);
                  layer.msg("信息完全一致不用更新！！");
              }
          });
      });
  });
  </script>
</body>
</html>